<template>
  <div>
    <el-form ref="form" :model="form" label-width="200px">
      <el-form-item label="订单号" prop="order">
        <el-input class="w500" v-model="form.order_code"></el-input>
      </el-form-item>
      <el-form-item label="商品ID">
        <el-input class="w500" v-model="form.goods_ids"></el-input>
      </el-form-item>
      <el-form-item label="该订单的商品总数">
        <el-input class="w500" v-model="form.goods_numbers"></el-input>
      </el-form-item>
      <el-form-item label="可抵用的最大积分值">
        <el-input class="w500" v-model="form.max_integral_deduction"></el-input>
      </el-form-item>
      <el-form-item label="订单总额(元)">
        <el-input class="w500" v-model="form.total_price"></el-input>
      </el-form-item>
      <el-form-item label="支付时抵用积分数量">
        <el-input class="w500" v-model="form.integral_deduction"></el-input>
      </el-form-item>
      <el-form-item label="积分抵扣的人民币(单位：分)">
        <el-input class="w500" v-model="form.integral_deduction_money"></el-input>
      </el-form-item>
      <el-form-item label="积分抵扣的亚数币个数">
        <el-input class="w500" v-model="form.integral_deduction_currency"></el-input>
      </el-form-item>
      <el-form-item label="商品名称/商品编码/订单编码">
        <el-input class="w500" type="textarea" v-model="form.search_fields" autosize></el-input>
      </el-form-item>
      <el-form-item label="订单用户账号">
        <el-input class="w500" v-model="form.user_info.name"></el-input>
      </el-form-item>
      <el-form-item label="支付方式">
        <el-radio-group v-model="form.pay_method">
          <el-radio label="cash">余额</el-radio>
          <el-radio label="currency">数字币</el-radio>
          <el-radio label="alipay">支付宝</el-radio>
          <el-radio label="wechat">微信支付</el-radio>
          <el-radio label="unionpay">银联支付</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="订单状态">
        <el-radio-group v-model="form.status">
          <el-radio label="0">未付款</el-radio>
          <el-radio label="1">支付成功</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="异常状态">
        <el-radio-group v-model="form.exceptions_status">
          <el-radio label="0">正常</el-radio>
          <el-radio label="1">取消</el-radio>
          <el-radio label="2">超时</el-radio>
          <el-radio label="3">冻结</el-radio>
          <el-radio label="4">仲裁/协商</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="创建时间">
        <el-date-picker v-model="form.pay_time" type="datetime" disabled></el-date-picker>
      </el-form-item>
      <el-form-item label="付款完成时间">
        <el-date-picker v-model="form.create_time" type="datetime" disabled></el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button @click="goBack">返回</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
  import { mapState } from 'vuex'

  export default {
    data: function () {
      return {
      }
    },
    computed: {
      ...mapState({
        form: state => state.order.orderInfo
      })
    },
    async created () {
      await this.orderInfo()
      this.form.status = String(this.form.status)
      this.form.exceptions_status = String(this.form.exceptions_status)
    },
    methods: {
      async orderInfo () {
        let payload = {
          id: this.$route.params.id
        }
        await this.$store.dispatch('order/orderInfo', payload)
      },
      goBack () {
        this.$router.go(-1)
      }
    }
  }
</script>
